package oakclub.entity;

import java.util.HashMap;
import java.util.Map;

public class RelationshipEntity extends BaseEntity
{
    private int id;

    public enum Relationship
    {
        UNKNOWN(0, "Unknown"), SINGLE(1, "Single"), COMPLICATED(2, "It's Complicated"),
        MARRIED(3, "Married"), IN_A_RELATIONSHIP(4, "In a Relationship"), ENGAGED(5, "Engaged"),
        IN_AN_OPEN_RELATIONSHIP(6, "In an Open Relationship"), WIDOWED(7, "Widowed"),
        SEPARATED(8, "Separated"), DIVORCED(9, "Divorced");

        private final int id;
        private final String name;

        private Relationship(int id, String name)
        {
            this.id = id;
            this.name = name;
        }

        public int getId()
        {
            return this.id;
        }

        public String getName()
        {
            return this.name;
        }

        private static final Map<Integer, Relationship> lookup = new HashMap<>();

        static
        {
            for(Relationship relationship : Relationship.values())
            {
                lookup.put(relationship.id, relationship);
            }
        }

        public static String getName(int id)
        {
            Relationship relationship = lookup.get(id);
            if(relationship == null)
            {
                return UNKNOWN.getName();
            }

            return relationship.getName();
        }
    }

    public RelationshipEntity()
    {

    }

    public RelationshipEntity(int id)
    {
        this.id = id;
    }

    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    public String getName()
    {
        return Relationship.getName(this.id);
    }
}
